/*
 * Copyright (C) 2010 Seapeak.Xu
 *
 * fostmq may be copied only under the terms of the GNU General
 * Public License V3, which may be found in the fostmq source kit.
 *
 * Created on: 2010-7-28
 * Author: Seapeak.Xu
 */

#ifndef FOST_MEM_H
#define FOST_MEM_H
#ifdef __cplusplus
extern "C"
{
#endif

#include <stdio.h>
#include <stddef.h>

#include "fost_typedef.h"

void fost_mem_init(void);	
/*
 * allocates memory to the pointer,
 * reutrn the memory pointer
 *
 * parameters:
 * 	size:memory length
 */
void *fost_malloc(size_t size);

/*
 * free the memory pointer and set null to the pointer
 *
 * parameters:
 * 	ptr:the pointer's memory address
 */
void fost_free(void **ptr);

/* 
 * allocates memory to the pointer and set the memory block to 0,
 * return the memory pointer
 *
 * parameters:
 * 	numbs:the count of elements
 * 	size:the element's size
 * */
void *fost_calloc(size_t numbs,size_t size);
/*
 * allocates the memory for string,add the end '\0' is auto
 */
char *fost_mallocs(size_t size);

/* 
 * allocates the memory for string,add the end '\0' is auto
 **/
char *fost_callocs(size_t numbs);

/*
 * allocates memory to the signal object  
 */
 void *fost_calloc1(size_t size);

 /* 
#define FOST_MALLOC(type,ptr,size) do\
{\
	ptr = (type *) malloc(size);\
}while(false);\

#define FOST_CALLOC(type,ptr,numbs,size) do\
{\
	ptr = (type *) calloc(numbs,size); \
}while(false);\
*/

//#define FOST_FREE(ptr)   

  
#define FOST_FREE(ptr) do\
{\
	if(NULL != ptr)\
	{\
		free(ptr);\
		ptr = NULL; \
	}\
}while(false); \


#ifdef __cplusplus
}
#endif
#endif /* FOST_MEM_H */
